/**
 * Created By zhangQ 2018/2/14
 */
import axiosUtils from '@api/env/axiosEnv'

let customAxios = axiosUtils._initAxios()

export function loginByUsername (username, password) {
  return customAxios({
    url: '/login',
    method: 'post',
    data: {
      username: username,
      password: password
    }
  })
}

export function getuserinfo () {
  return customAxios({
    url: '/common/user/getUserInfo',
    method: 'post'
  })
}

export function updatePwd (param) {
  return customAxios({
    url: '/updatePwd',
    method: 'post',
    data: {
      newPwd: param.newPwd
    }
  })
}

export function checkUser (param) {
  return customAxios({
    url: '/checkUser',
    method: 'post',
    data: {
      type: param.type,
      value: param.value
    }
  })
}

export function checkUserInfo (param) {
  return customAxios({
    url: '/checkUserInfo',
    method: 'post',
    data: {
      type: param.type,
      value: param.value
    }
  })
}

export function forgetPwdSMS (param) {
  return customAxios({
    url: '/forgetPwdSMS',
    method: 'post',
    data: {
      mobilePhone: param.mobilePhone,
      verifyCode: param.verifyCode
    }
  })
}

export function updateForgetPwd (param) {
  return customAxios({
    url: '/updateForgetPwd',
    method: 'post',
    data: {
      userName: param.userName,
      newPwd: param.newPwd
    }
  })
}

export function getGtConf () {
  return customAxios({
    url: '/gtcheck/getGtConf?date=' + new Date(),
    method: 'post',
    data: {}
  })
}

// 修改用户信息
export function updateUserInfo (param) {
  return customAxios({
    headers: {'Content-Type': 'multipart/form-data'},
    url: '/updateUserInfo2',
    method: 'post',
    data: param
  })
}
